<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>充值点列表</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../../js/layui/css/layui.css" media="all">
    <style type="text/css">
        .layui-table-cell{height:40px;line-height:40px;}
    </style>
</head>
<body >
<!--搜索框-->
<!--<div class="layui-form">-->
<!--    <div class="layui-form-item" style="margin-bottom: 30px;text-align: center;">-->
<!--        <div class="layui-inline">-->
<!--            &lt;!&ndash;<label class="layui-form-label">员工姓名或编号</label>&ndash;&gt;-->
<!--            <div class="layui-input-inline">-->
<!--                <input type="text" name="name" placeholder="请输入姓名" autocomplete="off" class="layui-input" />-->
<!--            </div>-->
<!--        </div>-->
<!--        <div class="layui-inline">-->
<!--            <button class="layui-btn layuiadmin-btn-list" lay-submit lay-filter="search-qiye-submit">-->
<!--                <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>-->
<!--            </button>-->
<!--        </div>-->
<!--    </div>-->
<!--</div>-->

<blockquote class="layui-elem-quote quoteBox mod_default_box">
    <form class="layui-form">
        <div class="layui-inline">
            <label class="layui-form-label" style="width: 50px;">关键字</label>
            <div class="layui-input-inline">
                <input type="text" id="name" name="name" placeholder="充值点名称" autocomplete="off" class="layui-input" />
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label" style="width: 50px;">状态</label>
            <div class="layui-input-inline">
                <select id="status" name="status">
                    <option value="">全部</option>
                    <option value="1">有效</option>
                    <option value="0">无效</option>
                </select>
            </div>
        </div>
        <div class="layui-inline">
            <button class="layui-btn layuiadmin-btn-list" lay-submit lay-filter="search-station-submit">
                <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
            </button>
        </div>

    </form>
</blockquote>
<!--<blockquote class="layui-elem-quote quoteBox mod_default_box">-->
    <!--<form class="layui-form">-->
        <!--<div class="layui-inline">-->
            <!--<label class="layui-form-label">物业</label>-->
            <!--<div class="layui-input-inline">-->
                <!--<select name="city" lay-verify="" lay-filter="wuye" id="wuye" lay-search>-->
                    <!--<option value="">选择物业</option>-->
                <!--</select>-->
            <!--</div>-->
        <!--</div>-->
        <!--<div class="layui-inline">-->
            <!--<label class="layui-form-label">企业</label>-->
            <!--<div class="layui-input-inline">-->
                <!--<select name="city" lay-verify="" lay-filter="qiye" id="qiye" lay-search>-->
                    <!--<option value="">选择企业</option>-->
                <!--</select>-->
            <!--</div>-->
        <!--</div>-->
        <!--<div class="layui-inline">-->
            <!--<label class="layui-form-label">姓名或编号</label>-->
            <!--<div class="layui-input-inline">-->
                <!--<input type="text" class="layui-input searchVal" name="name" placeholder="请输入姓名或编号" />-->
            <!--</div>-->
            <!--<a class="layui-btn  search_btn" data-type="reload">搜索</a>-->
        <!--</div>-->
    <!--</form>-->
<!--</blockquote>-->
<div style="display: none" id="batchAdd"></div>
<!--数据列表-->
<table class="layui-hide" id="recharge-station" lay-filter="recharge-station-table"></table>
<script type="text/html" id="station-toolbar">
    {{# if( d.status==1) { }}
    <a class="layui-btn  layui-btn-xs" lay-event="edit"><i class="layui-icon layui-icon-edit"></i>编辑</a>
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="delete"><i class="layui-icon layui-icon-delete"></i>删除</a>
    <a class="layui-btn layui-btn-checked layui-btn-xs" lay-event="resetPwd"><i class="layui-icon layui-icon-password"></i>重置密码</a>
    {{# } }}
</script>

<script src="../../js/layui/layui.js"></script>
<script src="../../js/layui/layui.all.js"></script>
<script src="../../js/token.js"></script>
<script src="../../js/config.js"></script>

<script>
    layui.use(['table','upload'], function() {
        var $ = layui.$;
        var table = layui.table;
        var layer = layui.layer;
        var form = layui.form;

        var name = ""
        var status = "";

        table.render({
            elem: '#recharge-station'
            , id: 'station-table-id'//重载需要
            , url: HOST+'recharge/station/list'
            , title: '充值点表'
                ,toolbar: '#tb'
            , cols: [[
                {type: 'numbers',title: '序号', width: 70}
                , {field: 'name', width: 110, align: 'center', title: '名称'}
                , {field: 'lianxiren', width: 110, align: 'center', title: '联系人'}
                , {field: 'phone', width: 110, align: 'center', title: '联系电话'}
                , {field: 'dayRechargeLimit', width: 110, align: 'center', title: '单日限额'}
                , {field: 'oneRechargeLimit', width: 110, align: 'center', title: '单笔限额'}
                , {field: 'deposit', width: 110, align: 'center', title: '保证金'}
                , {field: 'createTime', width: 210, align: 'center', title: '创建时间'}
                , {field: 'updateTime', width: 210, align: 'center', title: '最后更新时间'}
                , {field: 'status',align : 'center',width : 125, title: '状态',templet: function (d) {
                        if (d.status==0) return "无效";
                        else if (d.status==1) return "有效";
                    }
                }
                , {toolbar: "#station-toolbar",align : 'center', width: 300, title: "操作",fixed: 'right'}
            ]]
            , page: true
            ,page: {
                curr: layui.data("staff_page").index
            },
            done: (res, curr, count) => {
                layui.data("staff_page", {
                    key: 'index',
                    value: curr
                });
            }
        });

        //搜索操作
        form.on('submit(search-station-submit)', function (data) {
            //name = data.field.name;
                //status = data.field.status;
            table.reload('station-table-id', {
                where: {"name": data.field.name,"status":data.field.status}
                , page: {
                    curr: 1
                }
            });
            return false;
        });

        //表操作  监听操作
        table.on('tool(recharge-station-table)', function (obj) {
            var data=obj.data;
            var event = obj.event;
            //删除
            if (event === 'delete') {
                layer.confirm('确认删除该充值点吗？', function (index) {
                    $.ajax({
                        url: HOST+"recharge/station/delete?id=" + data.id
                        , type: "GET"
                        , dataType: "json"
                        , success: function (data) {
                            if (data.code == 0) {
                                layer.msg("删除成功");
                                table.reload("station-table-id");
                            } else {
                                layer.msg("删除失败");
                            }
                        }
                        , error: function () {
                            console.log("ajax error");
                        }
                    });
                    layer.close(index);
                });
            } else if (event === 'edit') {
                var data = obj.data;
                layer.open({
                    type:2
                    ,title:"编辑充值点信息"
                    ,skin:'layui-layer-molv'
                    ,area: ['95%', '99%']
                    ,content:(encodeURI("station_update.html?id="+data.id+"&name="+data.name+"&dayRechargeLimit="+data.dayRechargeLimit+"&oneRechargeLimit="+data.oneRechargeLimit+"&deposit="+data.deposit+"&createTime="+data.createTime+"&status="+data.status
                       ))  //js获取url参数
                    ,success: function (index, layero) {
                        // 这里是这个弹出层打开完成后所进行的操作
                        // form.ready();
                    }
                });
            }else if(event =="resetPwd"){
                layer.confirm('确认重置登录密码吗？', function (index) {
                    $.ajax({
                        url: HOST+"recharge/station/resetPwd?id=" + data.id
                        , type: "GET"
                        , dataType: "json"
                        , success: function (data) {
                            if (data.code == 0) {
                                layer.msg("操作成功");
                                table.reload("station-table-id");
                            } else {
                                layer.msg("操作失败");
                            }
                        }
                        , error: function () {
                            console.log("ajax error");
                        }
                    });
                    layer.close(index);
                });
            }

        });
    });
</script>


</body>
</html>